Example 2 application of derivatives